import { createAlova } from 'alova'
import NuxtHook from 'alova/nuxt'
import { useNuxtApp } from '#app'
import adapterFetch from 'alova/fetch'

const { public: { apiBase } } = useRuntimeConfig()

const alovaInstance = createAlova({
  requestAdapter: adapterFetch(),
  statesHook: NuxtHook({
    nuxtApp: useNuxtApp
  }),
  cacheFor: null,
  baseURL: apiBase,
  responded: response => response.json(),
})
export default alovaInstance
